package com.shengde.jinwawaforleader.model.personalCenter.activity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.shengde.jinwawaforleader.R;
import com.shengde.jinwawaforleader.base.BaseActivity;
import com.shengde.jinwawaforleader.model.myJob.instance_message.Constant;

/**
 * Created by Administrator on 2016/11/16 0016.
 */
public class EditBabySexyActivity extends BaseActivity {
	private static final String TAG = "EditBabySexyActivity";
	private TextView tv_back;
	private TextView tv_title;
	private TextView fill_add;
	private RadioGroup radio_gp;
	String mSexy;
	private String type;
	private RadioButton btn_radio_man;
	private RadioButton btn_radio_woman;

	@Override
	public void onRoot(Bundle savedInstanceState) {
		setContentView(R.layout.edit_baby_sexy_activity);
	}

	@Override
	public void initView() {
		tv_back = (TextView) findViewById(R.id.tv_back);
		tv_title = (TextView) findViewById(R.id.tv_title);
		fill_add = (TextView) findViewById(R.id.fill_add);
		radio_gp = (RadioGroup) findViewById(R.id.radio_gp);
		btn_radio_man = (RadioButton) findViewById(R.id.btn_radio_man);
		btn_radio_woman = (RadioButton) findViewById(R.id.btn_radio_woman);
	}

	@Override
	public void initData() {
		type = getIntent().getStringExtra("select_radio");
		if ("1".equals(type) || "3".equals(type) || "4".equals(type)||"6".equals(type)) {
			btn_radio_man.setText(getString(R.string.man));
			btn_radio_woman.setText(getString(R.string.woman));
			tv_title.setText(getString(R.string.sexy));
		} else if ("2".equals(type)) {
			btn_radio_man.setText(getString(R.string.kingarden_class));
			btn_radio_woman.setText(getString(R.string.kingarden_branh));
			tv_title.setText(getString(R.string.select_class_type));
		} else if ("5".equals(type)) {
			btn_radio_man.setText(getString(R.string.teacher_of_class_number_one));
			btn_radio_woman.setText(getString(R.string.teacher_of_class_number_two));
			tv_title.setText(getString(R.string.select_teacher_type));
		}else if ("7".equals(type)){
			btn_radio_man.setText(getString(R.string.is_teacher));
			btn_radio_woman.setText(getString(R.string.is_not_teacher));
			tv_title.setText(getString(R.string.is_or_teacher));
		}
		fill_add.setText(getString(R.string.save));
	}

	@Override
	public void initListener() {
		tv_back.setOnClickListener(this);
		fill_add.setOnClickListener(this);
		radio_gp.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
			@Override
			public void onCheckedChanged(RadioGroup group, int checkedId) {
				//获取变更后的选中项的ID
				int radioButtonId = group.getCheckedRadioButtonId();
				//根据ID获取RadioButton的实例
				RadioButton rb = (RadioButton) EditBabySexyActivity.this.findViewById(radioButtonId);
				Log.i(TAG, "onCheckedChanged: rb" + rb.getText());
				mSexy = (String) rb.getText();

			}
		});
	}

	@Override
	public void onWidgetClick(View view) {
		switch (view.getId()) {
			case R.id.tv_back:
				finish();
				break;
			case R.id.fill_add:
				Intent intent = new Intent();
				Bundle bundle = new Bundle();
				if ("1".equals(type) || "3".equals(type)||"4".equals(type)||"6".equals(type)) {

					bundle.putString("mSexy", mSexy);
					intent.putExtras(bundle);
					setResult(Constant.SETTING_SEXY_SAVE_SUCCESS, intent);
				} else if ("2".equals(type)) {
					bundle.putString("mClassType", mSexy);
					intent.putExtras(bundle);
					setResult(Constant.SETTING_CLASS_TYPE_SAVE_SUCCESS, intent);
				}else if ("5".equals(type)){
					bundle.putString("mTeacherType", mSexy);
					intent.putExtras(bundle);
					setResult(Constant.SETTING_TEACHER_TYPE_SAVE_SUCCESS, intent);
				}else if ("7".equals(type)){
					bundle.putString("isGuardian", mSexy);
					intent.putExtras(bundle);
					setResult(Constant.SETTING_IS_GUARDIAN_SAVE_SUCCESS, intent);
				}
				finish();
		}
	}
}
